package com.duoec.dw.lineage.core.conf;

import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author xuwenzhen
 */
@Configuration
@ConditionalOnMissingBean(OkHttpClient.class)
public class OkHttp3Configure {
    @Bean
    public OkHttpClient getOkHttpClient() {
        return new OkHttpClient.Builder()
                // .callTimeout(5, TimeUnit.SECONDS) //3.x版本不支持此方法！！
                .readTimeout(5, TimeUnit.SECONDS)
                .writeTimeout(5, TimeUnit.SECONDS)
                .connectTimeout(5, TimeUnit.SECONDS)
                .build();
    }
}
